package com.zhl.time2;

import java.util.Calendar;
import java.util.Date;

public class TestCalendar {
    public static void main(String[] args) {
        //目标：掌握Calandar类的使用和特点
        //1.得到系统此刻时间对应的日历对象。
        Calendar now = Calendar.getInstance();
        System.out.println(now);

        //2.获取日历中的某个信息
        int year = now.get(Calendar.YEAR);
        System.out.println(year);

        int days = now.getActualMaximum(Calendar.DAY_OF_MONTH);
        System.out.println(days);

        //3.拿到日历中记录的日期对象
        Date d = now.getTime();
        System.out.println(d);

        //4.拿到日期毫秒值
        long timeInMillis = now.getTimeInMillis();
        System.out.println(timeInMillis);

        //5.修改日历中的信息
        now.set(Calendar.YEAR, 2026);   //修改年份
        now.set(Calendar.MONTH, 11);   //修改月份
        System.out.println(now.get(Calendar.YEAR));
        System.out.println(now.get(Calendar.MONTH));
    }
}
